﻿using System.Collections.Generic;

namespace ShkSimulation.core.util {
    
    public class PriorityQueue<TValue> : DuplicateSortedList<TValue, int> {
        
        public PriorityQueue(IDuplicateComparer<TValue> comparer) : base(comparer) { }
        
        public PriorityQueue(IList<TValue> items, IDuplicateComparer<TValue> comparer) : base(comparer) {
            foreach (var item in items) {
                this.Add(item, 0);
            }
        }

        public void Add(TValue value) {
            Add(value, 0);
        }
        
        public new TValue RemoveFirstAndGetValue() {
            TValue value = default(TValue);
            if (this.Count == 0) {
                return value;
            }
            value = Keys[0];
            RemoveAt(0);
            return value;
        }

        public TValue GetFirst() {
            TValue value = default(TValue);
            if (this.Count == 0) {
                return value;
            }
            value = Keys[0];
            return value;
        }
    }
}
